Quaqua 4.4.7 2008-07-16

ch.randelshofer.quaqua.tiger.filechooser
Class OSXTigerFileSystemView

java.lang.Object
  extended by javax.swing.filechooser.FileSystemView
      extended by ch.randelshofer.quaqua.filechooser.FileSystemViewFilter
          extended by ch.randelshofer.quaqua.filechooser.QuaquaFileSystemView
              extended by ch.randelshofer.quaqua.tiger.filechooser.OSXTigerFileSystemView

public class OSXTigerFileSystemView
extends QuaquaFileSystemView

A file system view for Mac OS X 10.4 (Tiger).

Note: This file system view only works on top of Apple's Macintosh Runtime for Java.

Version:
1.2 2007-01-24 Determine system volume lazily. Create FileView lazily.
1.1 2006-09-23 Don't include "Computer" in getRoots().
1.0 2006-05-07 Created.
Author:
Werner Randelshofer

Field Summary
 
Fields inherited from class ch.randelshofer.quaqua.filechooser.FileSystemViewFilter
target
 
Constructor Summary
OSXTigerFileSystemView()
           
 
Method Summary
 java.io.File getChild(java.io.File parent, java.lang.String fileName)
           
 java.io.File getComputer()
          Returns the file that represents this computer node.
 java.io.File getDefaultDirectory()
          Return the user's default starting directory for the file chooser.
 javax.swing.filechooser.FileView getFileView()
           
 java.io.File getHomeDirectory()
           
 java.io.File getParentDirectory(java.io.File dir)
          Returns the parent directory of dir.
 java.io.File[] getRoots()
          Returns all root partitians on this system.
 java.lang.String getSystemDisplayName(java.io.File f)
          Name of a file, directory, or folder as it would be displayed in a system file browser.
 javax.swing.Icon getSystemIcon(java.io.File f)
          Icon for a file, directory, or folder as it would be displayed in a system file browser.
 java.lang.String getSystemTypeDescription(java.io.File f)
          Type description for a file, directory, or folder as it would be displayed in a system file browser.
 java.io.File getSystemVolume()
          Returns the file that represents the system (boot) volume of this computer.
 boolean isComputerNode(java.io.File dir)
          Used by UI classes to decide whether to display a special icon for a computer node, e.g.
 boolean isDrive(java.io.File dir)
          Used by UI classes to decide whether to display a special icon for drives or partitions, e.g.
 boolean isFileSystem(java.io.File f)
          Checks if f represents a real directory or file as opposed to a special folder such as "Desktop".
 boolean isFileSystemRoot(java.io.File dir)
          Is dir the root of a tree in the file system, such as a drive or partition.
 boolean isFloppyDrive(java.io.File dir)
          Used by UI classes to decide whether to display a special icon for a floppy disk.
 boolean isHiddenFile(java.io.File f)
          Returns whether a file is hidden or not.
 boolean isParent(java.io.File folder, java.io.File file)
          On Windows, a file can appear in multiple folders, other than its parent directory in the filesystem.
 boolean isRoot(java.io.File aFile)
          Determines if the given file is a root partition or drive.
 java.lang.Boolean isTraversable(java.io.File f)
          Returns true if the file (directory) can be visited.
 
Methods inherited from class ch.randelshofer.quaqua.filechooser.QuaquaFileSystemView
createFileView, getQuaquaFileSystemView
 
Methods inherited from class ch.randelshofer.quaqua.filechooser.FileSystemViewFilter
createFileObject, createFileObject, createNewFolder, getFiles
 
Methods inherited from class javax.swing.filechooser.FileSystemView
createFileSystemRoot, getFileSystemView
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OSXTigerFileSystemView

public OSXTigerFileSystemView()
Method Detail

getFileView

public javax.swing.filechooser.FileView getFileView()

getSystemVolume

public java.io.File getSystemVolume()
Description copied from class: QuaquaFileSystemView
Returns the file that represents the system (boot) volume of this computer.

Specified by:
getSystemVolume in class QuaquaFileSystemView

getComputer

public java.io.File getComputer()
Description copied from class: QuaquaFileSystemView
Returns the file that represents this computer node.

Specified by:
getComputer in class QuaquaFileSystemView

getParentDirectory

public java.io.File getParentDirectory(java.io.File dir)
Returns the parent directory of dir. This method returns the system volume instead of the computer folder ("/").

Overrides:
getParentDirectory in class FileSystemViewFilter
Parameters:
dir - the File being queried
Returns:
the parent directory of dir, or null if dir is null

getRoots

public java.io.File[] getRoots()
Returns all root partitians on this system. This method returns the contents of the volumes folder. The computer folder ("/") is considered as hidden and not returned by this method.

Overrides:
getRoots in class FileSystemViewFilter

isHiddenFile

public boolean isHiddenFile(java.io.File f)
Returns whether a file is hidden or not.

Overrides:
isHiddenFile in class FileSystemViewFilter

isRoot

public boolean isRoot(java.io.File aFile)
Determines if the given file is a root partition or drive.

Overrides:
isRoot in class FileSystemViewFilter
Parameters:
aFile - a File object representing a directory
Returns:
true if f is a root in the navigatable tree.
See Also:
FileSystemViewFilter.isFileSystemRoot(java.io.File)

isTraversable

public java.lang.Boolean isTraversable(java.io.File f)
Returns true if the file (directory) can be visited. Returns false if the directory cannot be traversed.

Specified by:
isTraversable in class FileSystemViewFilter
Parameters:
f - the File
Returns:
true if the file/directory can be traversed, otherwise false
See Also:
JFileChooser.isTraversable(java.io.File), FileView.isTraversable(java.io.File)

getSystemDisplayName

public java.lang.String getSystemDisplayName(java.io.File f)
Name of a file, directory, or folder as it would be displayed in a system file browser. Example from Windows: the "M:\" directory displays as "CD-ROM (M:)" The default implementation gets information from the ShellFolder class.

Specified by:
getSystemDisplayName in class FileSystemViewFilter
Parameters:
f - a File object
Returns:
the file name as it would be displayed by a native file chooser
See Also:
JFileChooser.getName(java.io.File)

getSystemTypeDescription

public java.lang.String getSystemTypeDescription(java.io.File f)
Type description for a file, directory, or folder as it would be displayed in a system file browser. Example from Windows: the "Desktop" folder is desribed as "Desktop". Override for platforms with native ShellFolder implementations.

Specified by:
getSystemTypeDescription in class FileSystemViewFilter
Parameters:
f - a File object
Returns:
the file type description as it would be displayed by a native file chooser or null if no native information is available.
See Also:
JFileChooser.getTypeDescription(java.io.File)

getSystemIcon

public javax.swing.Icon getSystemIcon(java.io.File f)
Icon for a file, directory, or folder as it would be displayed in a system file browser. Example from Windows: the "M:\" directory displays a CD-ROM icon. The default implementation gets information from the ShellFolder class.

Specified by:
getSystemIcon in class FileSystemViewFilter
Parameters:
f - a File object
Returns:
an icon as it would be displayed by a native file chooser
See Also:
JFileChooser.getIcon(java.io.File)

isParent

public boolean isParent(java.io.File folder,
                        java.io.File file)
On Windows, a file can appear in multiple folders, other than its parent directory in the filesystem. Folder could for example be the "Desktop" folder which is not the same as file.getParentFile().

Specified by:
isParent in class FileSystemViewFilter
Parameters:
folder - a File object repesenting a directory or special folder
file - a File object
Returns:
true if folder is a directory or special folder and contains file.

getChild

public java.io.File getChild(java.io.File parent,
                             java.lang.String fileName)
Specified by:
getChild in class FileSystemViewFilter
Parameters:
parent - a File object repesenting a directory or special folder
fileName - a name of a file or folder which exists in parent
Returns:
a File object. This is normally constructed with new File(parent, fileName) except when parent and child are both special folders, in which case the File is a wrapper containing a ShellFolder object.

isFileSystem

public boolean isFileSystem(java.io.File f)
Checks if f represents a real directory or file as opposed to a special folder such as "Desktop". Used by UI classes to decide if a folder is selectable when doing directory choosing.

Specified by:
isFileSystem in class FileSystemViewFilter
Parameters:
f - a File object
Returns:
true if f is a real file or directory.

isFileSystemRoot

public boolean isFileSystemRoot(java.io.File dir)
Is dir the root of a tree in the file system, such as a drive or partition. Example: Returns true for "C:\" on Windows 98.

Specified by:
isFileSystemRoot in class FileSystemViewFilter
Parameters:
dir - a File object representing a directory
Returns:
true if f is a root of a filesystem
See Also:
isRoot(java.io.File)

isDrive

public boolean isDrive(java.io.File dir)
Used by UI classes to decide whether to display a special icon for drives or partitions, e.g. a "hard disk" icon. The default implementation has no way of knowing, so always returns false.

Specified by:
isDrive in class FileSystemViewFilter
Parameters:
dir - a directory
Returns:
false always

isFloppyDrive

public boolean isFloppyDrive(java.io.File dir)
Used by UI classes to decide whether to display a special icon for a floppy disk. Implies isDrive(dir). The default implementation has no way of knowing, so always returns false.

Specified by:
isFloppyDrive in class FileSystemViewFilter
Parameters:
dir - a directory
Returns:
false always

isComputerNode

public boolean isComputerNode(java.io.File dir)
Used by UI classes to decide whether to display a special icon for a computer node, e.g. "My Computer" or a network server. The default implementation has no way of knowing, so always returns false.

Specified by:
isComputerNode in class FileSystemViewFilter
Parameters:
dir - a directory
Returns:
false always

getHomeDirectory

public java.io.File getHomeDirectory()
Overrides:
getHomeDirectory in class FileSystemViewFilter

getDefaultDirectory

public java.io.File getDefaultDirectory()
Return the user's default starting directory for the file chooser.

Specified by:
getDefaultDirectory in class FileSystemViewFilter
Returns:
a File object representing the default starting folder

Copyright 2003-2007 (c) Werner Randelshofer.
All rights reserved.